package com.zs.games.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.zs.games.resultTool.CimResponse;
import com.zs.games.entity.UserFeedback;
import com.zs.games.entity.UserInfo;
import com.zs.games.param.PageQuery;
import com.zs.games.param.UpdatePasswordParam;
import com.zs.games.param.UserIdParam;
import com.zs.games.service.UserInfoService;
import com.zs.games.vo.GameInfoVo;
import com.zs.games.vo.GameNewVo;
import com.zs.games.vo.UserBlackVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @date 2023年09月11日 11:16
 */
@RestController
@RequestMapping("/user")
@Api(value = "用户管理", tags = "用户管理")
public class UserInfoController {
    @Autowired
    private UserInfoService userInfoService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "修改用户信息接口", notes = "修改用户接口")
    @PostMapping("/updateUserInfo")
    public CimResponse<Boolean> updateUserInfo(@RequestBody UserInfo param){
        return CimResponse.okData(userInfoService.updateById(param));
    }
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "修改用户密码接口", notes = "修改用户密码接口")
    @PostMapping("/updatePassword")
    public CimResponse<Boolean> updatePassword(@RequestBody UpdatePasswordParam param){
        return CimResponse.okData(userInfoService.updatePassword(param));
    }

    @GetMapping("/myCollect")
    @ApiOperation("我的收藏")
    @ApiOperationSupport(order = 3)
    public CimResponse<List<GameNewVo>> myCollect() {
        return CimResponse.okData(userInfoService.getCollectList());
    }
    @GetMapping("/myLiveGames")
    @ApiOperation("我喜欢的游戏")
    @ApiOperationSupport(order = 3)
    public CimResponse<List<GameInfoVo>> myLiveGames() {
        return CimResponse.okData(userInfoService.getMyLiveGame());
    }
    @PostMapping("/accountClose")
    @ApiOperation("注销账号")
    @ApiOperationSupport(order = 4)
    public CimResponse<Boolean> accountClose() {
        return CimResponse.okData(userInfoService.accountClose());
    }

    @PostMapping("/feedBack")
    @ApiOperation("举报")
    @ApiOperationSupport(order = 5)
    public CimResponse<Boolean> feedBack(@RequestBody UserFeedback param) {
        return CimResponse.okData(userInfoService.feedBack(param));
    }

    @PostMapping("/addBlack")
    @ApiOperation("拉黑用户")
    @ApiOperationSupport(order = 6)
    public CimResponse<Boolean> addBlack(@RequestBody @Validated UserIdParam param) {
        return CimResponse.okData(userInfoService.addBlack(param));
    }
    @PostMapping("/delBlack")
    @ApiOperation("解除拉黑")
    @ApiOperationSupport(order = 7)
    public CimResponse<Boolean> delBlack(@RequestBody @Validated UserIdParam param) {
        return CimResponse.okData(userInfoService.delBlack(param));
    }
    @GetMapping("/myBlackList")
    @ApiOperation("我的拉黑列表")
    @ApiOperationSupport(order = 8)
    public CimResponse<IPage<UserBlackVo>> myBlackList(PageQuery param) {
        return CimResponse.okData(userInfoService.getBlackList(param));
    }

}
